package net.hn.hnms.biz.sewage.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.sewage.entity.DomesticSewageShiftEntity;
import net.hn.hnms.biz.sewage.service.DomesticSewageService;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.Map;

/**
 * @author 智呈物联 nzw
 * @date 2022/9/22
 */
@RestController
@RequestMapping("safety/sewage/domesticSewage")
@Api(value = "生活污水", tags = {"生活污水"})
public class DomesticSewageController {

    private DomesticSewageService domesticSewageService;

    @Autowired
    public void setDomesticSewageService(DomesticSewageService domesticSewageService) {
        this.domesticSewageService = domesticSewageService;
    }

    @ApiOperation("生活污水添加")
    @PostMapping("/add")
    public R add(@RequestBody DomesticSewageShiftEntity domesticSewageShiftEntity){
        domesticSewageService.save(domesticSewageShiftEntity);
        return R.ok();
    }

    @ApiOperation("生活污水修改")
    @PostMapping("/update")
    public R update(@RequestBody DomesticSewageShiftEntity domesticSewageShiftEntity){
        domesticSewageService.save(domesticSewageShiftEntity);
        return R.ok();
    }

    @ApiOperation("生活污水月度统计")
    @GetMapping("/findByMonth")
    @AutoSetMineCode
    public R<Map<String,Object>> findByMonth(String mineCode, String month) throws ParseException {
        return R.ok(domesticSewageService.findByMonth(mineCode,month));
    }
}
